package com.wdz.service.impl;

import com.wdz.admin.entity.Admin;
import com.wdz.currency_query.service.CurrencyQueryService;
import com.wdz.currency_query.utils.Param;
import com.wdz.service.IAdminService;
import com.wdz.utils.PageUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdminServiceImpl implements IAdminService {

    private CurrencyQueryService currencyQueryService = new CurrencyQueryService();


    @Override
    public Admin queryAdmin(String username) {
        Param param = new Param();
        param.keywords = param.new Keywords();
        param.keywords.setK_type(3);
        param.keywords.setK_cloum("admin_name");
        param.keywords.setK_value(username);
        PageUtil pageUtil = currencyQueryService.searchCurr("admin",param);
        List<Map<String, Object>> admins = (List<Map<String, Object>>) pageUtil.getData();
        Map<String, Object> admin = admins.get(0);
        Admin admin1 = new Admin();
        admin1.setId((String) admin.get("id"));
        admin1.setAdminName((String) admin.get("adminName"));
        admin1.setEmail((String) admin.get("email"));
        admin1.setLevel((Integer) admin.get("level"));
        admin1.setAvatar(admin.get("avatar").toString());
        admin1.setAuthorities(admin.get("authorities").toString());

        return admin1;
    }

    @Override
    public boolean checkUserName(String username) {

        return false;
    }

}
